package apis

import "net/http"

type Response struct {
	Code    int         `json:"code" yaml:"code"`
	Message string      `json:"message" yaml:"message"`
	Data    interface{} `json:"data" yaml:"data"`
}

func ResponseOK(data interface{}) Response {
	return Response{
		Code:    http.StatusOK,
		Message: "succeed",
		Data:    data,
	}
}

func ResponseReqErr(err error, data interface{}) Response {
	return Response{
		Code:    http.StatusBadRequest,
		Message: err.Error(),
		Data:    data,
	}
}

func ResponseUnauthorizedErr(err error, data interface{}) Response {
	return Response{
		Code:    http.StatusUnauthorized,
		Message: err.Error(),
		Data:    data,
	}
}

func ResponseInterErr(err error, data interface{}) Response {
	return Response{
		Code:    http.StatusInternalServerError,
		Message: err.Error(),
		Data:    data,
	}
}
